package com.atguigu.gmall.task.test;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling

public class ScheduledTask {
    @Autowired
    private RabbitService rabbitService;

    //开启定时任务
    @Scheduled(cron = "0/10 * * * * ?")
    public void test1() {
        System.out.println("终于结束了");
        this.rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"activity");
    }
}
